//
//  main.m
//  CopyTest
//
//  Created by wangrui on 13-8-12.
//  Copyright (c) 2013年 PPS. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

    @autoreleasepool {
        
        NSString *str = @"str";
        NSString *cstr = [str copy]; //浅拷
        NSLog(@"%p,%p",str,cstr);
        
        NSMutableString  *mstr = [str mutableCopy];//深拷
        [mstr appendString:@"mutable"];
        NSLog(@"%@",mstr);
        
        //可变对象
        NSMutableString *ms = [NSMutableString stringWithString:@"mu"];
        NSMutableString *msc = [ms copy];//深拷
        //[msc appendString:@"copy"];//这样会抛异常，copy返回的是一个不可变对象
        
        NSMutableString *msmc = [ms mutableCopy];//深拷
        [msmc appendString:@"mutablecopy"];
        
        NSLog(@"%p,%p,%p",ms,msc,msmc);
        NSLog(@"%@,%@,%@",ms,msc,msmc);
        
    }
    return 0;
}

